package com.itheima.controller;

import com.itheima.entity.Comment;
import com.itheima.service.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/comment")
public class CommentController {

    @Autowired
    private CommentService commentService;

    @GetMapping("/{id}")
    public Comment findComment(@PathVariable("id") Integer id){
        return commentService.findCommentById(id);
    }

    @GetMapping("/{id}/{content}")
    public Comment updateComment(@PathVariable("id") Integer id, @PathVariable("content") String content){
        return commentService.updateComment(id, content);
    }

    @GetMapping("/delete/{id}")
    public void deleteComment(@PathVariable("id") Integer id) {
        commentService.deleteCommentById(id);
    }
}
